package reflect;

import annotation.AutoRunClass;

import java.util.Scanner;

public class Test3 {
    public static void main(String[] args) throws ClassNotFoundException, InstantiationException, IllegalAccessException {
        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入类名:");
        String classname = scanner.nextLine();
        Class cls = Class.forName(classname);
        boolean mark = cls.isAnnotationPresent(AutoRunClass.class);
        if (mark){
            System.out.println("开始实例化对象:"+cls.getSimpleName());
            Object object = cls.newInstance();
            System.out.println(object);
        }else{
            System.out.println(cls.getSimpleName()+"类没有被注解标注!");
        }
    }
}
